package com.hfb.mashibing.alip8.designpattern._09observer;

import java.util.concurrent.TimeUnit;

/**
 * 题目：模拟 宝宝在睡觉，醒来后哭了，之后要喂奶
 * 面向对象的傻等，直到醒来
 */

public class V2 {

    public static void main(String[] args) throws InterruptedException {
        Child baby = new Child();
        while (!baby.isCry()) {
            TimeUnit.SECONDS.sleep(30);
            System.out.println("Observer ......");
        }

    }
}

class Child {
    private boolean cry = false;

    public boolean isCry() { return cry;}

    public void wakeUp(){
        cry = true;
        System.out.println("waked up! Crying! 555555555555555555");
    }
}
